//
//  GDHomeTitleButton.swift
//  weibo
//
//  Created by user on 15/11/27.
//  Copyright © 2015年 user. All rights reserved.
//

import UIKit

class GDHomeTitleButton: UIButton {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    init(title: String) {
        super.init(frame: CGRectZero)
        
        self.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        
        self.setTitle(title, forState: UIControlState.Normal)
        
        self.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        self.sizeToFit()
        
    }
    
    ///系统调用
    override func layoutSubviews() {
        //一定要调用父类的方法，不然子控件都看不到了
        super.layoutSubviews()
        
        //将标题移到最左边
        titleLabel?.frame.origin.x = 0
        
        //将图片移到titleLabel的右边
        imageView?.frame.origin.x = titleLabel!.frame.width + 3
        
        
    }

    
    
}
